package com.itcam.thread_.thread;

public class ThreadDemo2 {
    /*
        Java程序默认是多线程的, 程序启动后默认会存在两条线程
            1. 主线程
            2. 垃圾回收线程
     */
    public static void main(String[] args) {
        Thread mt = new Thread();
        mt.start();

        for (int i = 1; i <= 2000; i++) {
            System.out.println("main线程执行了");
        }

        // 制造垃圾
        for (int i = 1; i <= 500000; i++) {
            new Demo();
        }

    }
}

class Demo {
    @Override
    protected void finalize() throws Throwable {
        System.out.println("垃圾被清理了");
    }
}
